package com.weirong.smartvault.backservice.entity_model;


import com.weirong.smartvault.backservice.util.common.ListTool;
import com.weirong.smartvault.common.tools.spring.context.SpringContextUtil;
import com.weirong.smartvault.dao.ForeignCurrencyDenominationRepository;
import com.weirong.smartvault.entity.ForeignCurrencyType;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

/**
 * 于2017/12/8由 KFEB4 创建 .
 */
public class ForeignCurrencyTypeModel {
    ForeignCurrencyType type;

    ForeignCurrencyDenominationRepository foreignCurrencyDenominationRepository;

    public ForeignCurrencyTypeModel(ForeignCurrencyType type) {
        this.type = type;
        this.foreignCurrencyDenominationRepository = SpringContextUtil.getBean(ForeignCurrencyDenominationRepository.class);
    }

    public String getName() {
        return type.getName();
    }

    public String getCode() {
        return type.getCode();
    }

    public String getDescription() {
        return type.getDescription();
    }

    public String getUnit() {
        return type.getUnit();
    }

    public Integer getId() {
        return type.getId();
    }

    public List<ForeignCurrencyDenominationModel> getForeignCurrencyDenomination() throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
        return ListTool.cast(foreignCurrencyDenominationRepository.getForeignCurrencyDenominationByTypeCode(getCode()),ForeignCurrencyDenominationModel.class);
    }
}
